import React from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import './Result.css';

const ResultPage = () => {
    const location = useLocation();
    const navigate = useNavigate();
    const { answers, keywords } = location.state || { answers: [], keywords: [] };

    const score = Math.round(Math.random() * 5) + 1;  // 随机生成分数
    const feedback = [
        '回答不够详细，请加强。',
        '逻辑清晰，但需要更深入的知识。',
        '表现良好，继续加油！',
        '非常棒！回答全面且专业。',
    ][Math.min(score - 1, 3)];

    return (
        <div className="result-container">
            <h2>模拟面试结果</h2>
            <div className="result-content">
                <h4>关键字</h4>
                <div>{keywords.join(', ')}</div>
                <h4>分数: {score} 分</h4>
                <h4>评语: {feedback}</h4>
            </div>
            <button className="retry-btn" onClick={() => navigate('/inter-list')}>再面一次</button>
        </div>
    );
};

export default ResultPage;
